1. Field of the Invention
The present invention relates to an apparatus for calculating optical flow and camera motion using correlation matching and a system model in a moving image, and more particularly, to an apparatus for calculating optical flow and camera motion using correlation matching and a system model in a moving image, in which after the optical flow is acquired from a sequence of moving images, the camera motion is calculated.
2. Background of the Related Art
Up to now, in order to calculate an optical flow by extracting feature points in a sequence of moving images, a gradient-based approach, a frequency-based approach, and a correlation-based approach have been proposed.
The Hron and Schunck algorithm is typical of the gradient-based approach.
According to such an approach, a pixel point is found with a value that is minimized according to a variation of a peripheral pixel gray value and a variation of a gray value between image frames. The greatest disadvantage of the algorithm is that since the gray value existing in a current frame has to be in a next frame and an object may have moved, it is difficult to apply this approach to quick camera motion and thus to the system in real time.
The frequency-based approach of calculating the optical flow uses a differential value of all of pixel values in the image by employing a band-pass filter for a velocity such as a Gabor filter. This approach also has the same disadvantage as that of the gradient-based approach.
The correlation-based approach is applied to a method of searching a moving object in an MPEG image. The approach has many errors when the image is rotated or a zoom level change occurs, such that an auxiliary method is then required.
Thus, according to the existing methods it is not possible to calculate optical flow in real time, because of calculating the optical flow for all the pixels in the image. The optical flow calculation using correlation matching has a drawback in that, upon the occurrence of an image rotation or zoom change, errors occur in the calculation of the optical flow.
Accordingly, the present invention is directed to an apparatus for calculating optical flow and camera motion using correlation matching and a system model in a moving image that substantially obviates one or more problems due to limitations and disadvantages of the related art.
An object of the present invention is to provide an apparatus for calculating optical flow and camera motion using correlation matching and a system model in a moving image, in which optical flow is calculated in real time, and may be calculated accurately even when an image rotation or zoom change occurs.
To achieve these objects and other advantages, the present invention employs a method of calculating the optical flow on the basis of a correlation-based approach and using an estimated value, whereby the optical flow calculated in a previous frame is to be positioned in a current frame, on the basis of the system model and the camera motion calculated in the previous frame, upon the occurrence of an image rotation or zoom level change.
In addition, since real time processing is impossible when the optical flow of all of the pixels is calculated, the number of optical flows is controlled so as not to be increased above a certain number by use of a SUSAN edge operation. When calculating the optical flow, the method of combining a correlating matching value with an optical flow location estimated value is characterized in that a correlation matching weighted value is reduced depending upon a rotating and moving value of an optical axis of a CCD camera.
According to one aspect of the present invention, there is provided an apparatus for calculating optical flow and camera motion using correlation matching and a system model in moving images. The apparatus includes a feature point extracting section for extracting a feature point of a sequence of input images (previous image and current image); an optical flow calculating section for calculating an optical flow by use of the feature points extracted by the feature point extracting section; a first camera motion calculating section for calculating a camera motion by use of the optical flow calculated by the optical flow calculating section; a second camera motion calculating section for eliminating an incorrect optical flow among the optical flows calculated by the optical flow calculating section and recalculating camera motion; an optical flow location estimating section for estimating a location of the optical flow by estimating a distance difference between an estimated feature point location and a current feature point location in the previous image according to the camera motion calculated by the second camera motion calculating section; and a weighted value calculating section for calculating a weighted value according to the camera motion calculated by the second camera motion calculating section and providing the weighted value to the optical flow calculating section.
The feature point extracting section comprises a SUSAN edge driving portion for extracting an edge image from the sequence of the input images, and a local max portion for selecting a largest value in a mask size region set in the edge image extracted from the SUSAN edge extracting portion to extract a certain number of feature points. The feature points are extracted by the local max portion in accordance with:   S  =            {                        ∑          e                ⁢                  xe2x80x83                ⁢                  -                                    (                                                                    I                    ⁡                                          (                                              x                        ,                        y                                            )                                                        -                                      I                    ⁡                                          (                                                                        x                          +                          dx                                                ,                                                  y                          +                          dy                                                                    )                                                                      T                            )                        6                              }        /    G  
wherein, I is a gray value, T is a threshold value for a difference between the gray values, and G is an edge strength difference between feature point locations of the previous and current images.
The optical flow calculating section comprises a combining subsection for calculating a connecting strength of an edge by use of the information relating to the distance difference between the current feature point location and the estimated feature point location in the previous image provided from the optical flow location estimating section, the weighted values of the correlation, location incorrectness, and edge strength matching provided from the feature point extracting section, and the edge strength difference between the feature points of the previous and current images provided from the feature point extracting section; and a matched feature point extracting subsection for extracting the feature points having the largest connecting strength by use of the connecting strength value provided from the combining subsection and providing the extracted feature points to the first and second camera motion calculating sections. The edge connecting strength E is calculated by the combining subsection in accordance with:
E=WGG+WClCl+WSS
wherein, WG is a weighted value of a correlation matching, WCl is a weighted value of a location error matching, WS is a weighted value of an edge strength matching, G is an edge strength difference between the feature point locations in the previous and current images provided from the feature point extracting section, Cl is a distance difference between the current feature point location and the estimated feature point location in the previous image provided from the optical flow location estimating section, and S is a SUSAN edge strength difference between the feature points of the previous and current images provided from the feature point extracting section.
The first camera motion calculating section comprises a pseudo inverse matrix calculating subsection for calculating a constant of a camera projection formula by use of the optical flow provided from the optical flow calculating section; and a first camera motion calculating subsection for dividing the camera motion by use of the constant of the camera projection formula provided from the pseudo inverse matrix calculating subsection, and providing the resultant to the second camera motion calculating section.
The second camera motion calculating section comprises an optical flow direction and magnitude calculating subsection for calculating a direction and magnitude of the optical flow by use of the value of the camera motion calculated by the first camera motion calculating section; an incorrect optical flow eliminating subsection for eliminating an incorrect optical flow among the optical flows provided from the optical flow calculating section depending upon the direction and magnitude of the optical flow calculated by the optical flow direction and magnitude calculating subsection; and a second camera motion calculating subsection for calculating the camera motion using the optical flow which is not eliminated by the incorrect optical flow eliminating subsection, and providing the camera motion to the weighted value calculating section and the optical flow location estimating section, respectively. The direction and magnitude of the optical flow are calculated by the optical flow direction and magnitude calculating subsection in accordance with:       (                                        x            Ave                                                            y            Ave                                )    =            (                                                  x              t                                                                          y              t                                          )        +          Δ      ⁢              xe2x80x83            ⁢              t        ⁡                  (                                                                                                                -                                              T                                                  x                          ,                          y                                                                                      /                                          Z                      t                                                        +                                                            T                                              z                        ,                        t                                                              ⁢                                                                  x                        t                                            /                                              Z                        t                                                                              +                                                            Ω                                              z                        ,                        t                                                              ⁢                                          y                      t                                                                                                                                                                                      -                                              T                                                  y                          ,                                                      t                            +                            1                                                                                                                /                                          Z                      t                                                        +                                                            T                                              z                        ,                        t                                                              ⁢                                                                  y                        t                                            /                                              Z                        t                                                                              -                                                            Ω                                              z                        ,                        t                                                              ⁢                                          x                      t                                                                                                    )                    
wherein, xcex94t is a sampling time, Tx, Ty and Tz are x, y and z-axis translation of the camera, respectively, and xcexa9z is z-axis rotation of the camera, xt and yt are locations in the current frame image, and xAve and yAve are standard locations. If the direction xcex8 of a standard optical flow and the distance xcex94 between xAve and yAve are outside a predetermined range, the incorrect eliminating subsection determines the calculated optical flow as a mismatched optical flow to eliminate the incorrect optical flow.
The optical flow location estimating section estimates the camera motion, depending upon the optical flow, from which the incorrect optical flow has been eliminated, and the camera motion provided from the second camera motion calculating section, in accordance with:       (                                                      x              ^                                      t              +              1                                                                                      y              ^                                      t              +              1                                            )    =            (                                                  x              t                                                                          y              t                                          )        +          Δ      ⁢              xe2x80x83            ⁢              t        ⁡                  (                                                                                                                -                                                                        T                          ^                                                                          x                          ,                                                      t                            +                            1                                                                                                                /                                          Z                      t                                                        +                                                                                    T                        ^                                                                    z                        ,                                                  t                          +                          1                                                                                      ⁢                                                                  x                        t                                            /                                              Z                        t                                                                              +                                                                                    Ω                        ^                                                                    z                        ,                                                  t                          +                          1                                                                                      ⁢                                          y                      t                                                                                                                                                                                      -                                                                        T                          ^                                                                          y                          ,                                                      t                            +                            1                                                                                                                /                                          Z                      t                                                        +                                                                                    T                        ^                                                                    z                        ,                                                  t                          +                          1                                                                                      ⁢                                                                  y                        t                                            /                                              Z                        t                                                                              -                                                            Ω                                              z                        ,                                                  t                          +                          1                                                                                      ⁢                                          x                      t                                                                                                    )                    
wherein, {circumflex over (T)}x,t+1, {circumflex over (T)}y,t+1, {circumflex over (T)}x,t+1, {circumflex over (xcexa9)}x,t+1 are camera motion estimates.
The weighted value calculating section comprises a correlation matching weighted value calculating subsection for calculating a correlation matching weighted value by use of the camera motion from which the incorrect optical flow has been eliminated by the second camera motion calculating section; and a weighted value normalized calculating subsection for executing smoothing of a predetermined location estimated constant weighted value, an edge strength constant weighted value, and the calculated correlation matching weighted value, and providing each of the smoothed values to the optical flow calculating section. The correlation matching weighted value is calculated by the correlation matching weighted value calculating subsection in accordance with:
xe2x80x83W1=WG,Init+KTZ|TZ|+Kxcexa9Z|xcexa9Z|
wherein, WG,Init is an initial set value of the correlation matching weighted value.
The smoothing of the predetermined location estimated constant weighted value, the edge strength constant weighted value, and the calculated correlation matching weighted value are executed by the weighted value normalized calculating subsection in accordance with:             W      G        =                  W        1                              W          1                +                  W                      Cl            ,            Init                          +                  W                      S            ,            Init                                          W      Cl        =                  W                  Cl          ,          Init                                      W          1                +                  W                      Cl            ,            Init                          +                  W                      S            ,            Init                                          W      S        =                  W                  S          ,          Init                                      W          1                +                  W                      Cl            ,            Init                          +                  W                      S            ,            Init                              
wherein, WCl,Init and WS,Init are the location estimated weighted value and the edge strength constant weighted value, respectively.
It is to be understood that both the foregoing general description and the following detailed description of the present invention are exemplary and explanatory and are intended to provide further explanation of the invention as claimed.